import IButtonOptions from "@/components/ButtonGroup/button-scheme";
import InputType from '@/enum/InputType'
import {IFormConfig, IFormItem} from "@/components/Form/form-scheme";

const inputItems: IFormItem[] = [
    {
        model: 'dictName',
        type: InputType.INPUT,
        label: `名称:`,
        clearable: true
    },
    {
        model: 'dictType',
        type: InputType.INPUT,
        label: `标识:`,
        clearable: true
    },
]


const ButtonConfig: IButtonOptions = {
    reset: {
        clickCall: 'reset',
        btnTip: '重置'
    },
    query: {
        clickCall: 'query',
        btnTip: '查询'
    },
    add: {
        clickCall: 'openDialog',
        btnTip: '添加'
    },
    edit: {
        clickCall: 'openDialog',
        btnTip: '编辑'
    },
    delete: {
        clickCall: 'delete',
        btnTip: '删除'
    }
}

const SearchConfig: IFormConfig = {
    items: inputItems,
    labelWidth: "80px",
    span: 6
}



export {SearchConfig, ButtonConfig}

/**
 * 字典类型添加或更新form表单配置
 */
const formItems : IFormItem[] = [
    {
        model: 'dictName',
        type: InputType.INPUT,
        label: '类型名称',
        clearable: true,
        ruleName: 'dictName'
    },
    {
        model: 'dictType',
        type: InputType.INPUT,
        label: '类型标识',
        clearable: true,
        ruleName: 'dictType'
    },
    {
        model: 'remark',
        type: InputType.INPUT,
        label: '备注',
        clearable: true,
    }
]



const FormConfig: IFormConfig = {
    items: formItems,
    span: 24,
    rules: {
        dictName: [
            {required: true, message: '请输入字典类型名称', trigger: 'blur'},
            {min: 2, max: 15, message: '长度在 2 到 15 个字符', trigger: 'blur'}
        ],
        dictType: [
            {required: true, message: '请输入字典类型标识', trigger: 'blur'},
        ]
    }
}

let FormData =  {
        id: null,
        dictName: '',
        dictType: '',
        remark: ''
    }

export {FormConfig,FormData}



/**
 * 字典数据添加或更新form表单配置
 */
const formItems1 : IFormItem[] = [
    {
        model: 'label',
        type: InputType.INPUT,
        label: '字典值',
        clearable: true,
        ruleName: 'label'
    },
    {
        model: 'value',
        type: InputType.INPUT,
        label: '字典码',
        clearable: true,
        ruleName: 'value'
    },
    {
      model: 'isDefault',
      type: InputType.SELECT,
      label: '默认值',
      clearable: true
    },
    {
      model: 'order',
      type: InputType.INPUTNUMBER,
      label: '排序',
      clearable: true,
      min: 0,
      max: 10
    },
    {
        model: 'remark',
        type: InputType.INPUT,
        label: '备注',
        clearable: true,
    }
]



const FormConfig1: IFormConfig = {
    items: formItems1,
    span: 24,
    rules: {
        label: [
            {required: true, message: '请输入字典值', trigger: 'blur'},
            {min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur'}
        ],
        value: [
            {required: true, message: '请输入字典码', trigger: 'blur'},
            {min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur'}
        ]
    }
}

let FormData1 =  {
    id: null,
    label: '',
    value: '',
    type: null,
    isDefault: null,
    orderNum: 0,
    remark: ''
}

export {FormConfig1,FormData1}
